#include <iostream>
#include <vector>
using namespace std;

int n,a[1005],flag;
vector<int> v;

void dfs(int u){
    if(u>n){
        return;
    }
    v.push_back(a[u]);
    if(u*2+1>n&&u*2>n){
        cout<<v[0];
        for(int i=1;i<v.size();i++)    cout<<" "<<v[i];
        cout<<"\n";
        v.pop_back();
        return;
    }
    if(u*2+1<n){
        if(flag==1&&a[u]<a[u*2+1]||flag==0&&a[u]>a[u*2+1])    flag = -1;
    }
    dfs(u*2+1);
    if(u*2<n){
        if(flag==1&&a[u]<a[u*2]||flag==0&&a[u]>a[u*2])    flag = -1;
    }
    dfs(u*2);
    v.pop_back();
}

signed main()
{
    cin>>n;
    for(int i=1;i<=n;i++)    cin>>a[i];
    if(a[1]>a[2])    flag = 1;
    else    flag = 0;
    dfs(1);
    if(flag==1)    cout<<"Max Heap\n";
    else if(flag==0)    cout<<"Min Heap\n";
    else    cout<<"Not Heap\n";
    return 0;
}
